<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!-- 兼容性 -->
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <title>计划编制-专项计划编制及发布</title>
    <script src="/scripts/boot.js"></script>
    <style>
        html,body{
            margin:0;padding: 0;border:0;width:100%;height:100%;overflow:hidden;
        }
        body{
            background: #ffffff!important;
            padding:20px;
        }
    </style>
</head>
<body>
<div class="title-list mb-20"><span class="title-listbg"></span><span>项目专项计划</span></div>
<div class="container">
    <div class="mini-clearfix mb-10">
        <div class="mini-col-6 mini-col-sm-3">
            <a class="plan-btn mR-20"  onclick="list.addOrEdit('new')"><span class="add-bg"></span>新增</a>
        </div>
    </div>
</div>
<div class="mini-fit">
    <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;"  url="/professionalPlan/listByPage" sizeList="[5,10,20,50]" pageSize="20"  idField="id" multiSelect="true" showEmptyText="true" emptyText="暂无数据" alwaysShowEmptyText="true">
        <div property="columns">
            <div type="indexcolumn" headerAlign="center" allowSort="false">编号</div>
            <div field="id" width="120" headerAlign="center" allowSort="false" visible="false">id</div>
            <div field="itemName" width="120" headerAlign="center" allowSort="false">项目名称</div>
            <div field="keyPlanName" width="120" headerAlign="center" allowSort="false">主项计划</div>
            <div field="name" width="120" headerAlign="center" allowSort="false">专项计划</div>
            <div field="beginDate" width="100" headerAlign="center" align="center" allowSort="false" renderer="ondayRenderer">计划起止时间</div>
            <div field="createDate" width="100" headerAlign="center" align="center" allowSort="false" renderer="ondayRenderer">编制时间</div>
            <div field="state" width="100" headerAlign="center" align="center" allowSort="false">审批状态</div>
            <div name="action" width="150" headerAlign="center" align="center">操作</div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var list = {
        //页面初始化
        init: function() {
            mini.parse();
            mini.get("datagrid1").load();
            mini.get("datagrid1").on("drawcell", function (e) {
            	 var column = e.column;
                 if(column.field=="beginDate"){
                     var dateText = "";
                     if(e.row.beginDate&&e.row.endDate){
                         dateText="至"
                     }
                     e.cellHtml = e.row.beginDate.substring(0,10)+dateText+e.row.endDate.substring(0,10);
                 }
                 if(column.field=="state"){
                     if(e.value == 0){
                         e.cellHtml = "未提交";
                     }else if (e.value == 1){
                         e.cellHtml = "审批中";
                     }else if (e.value == 2){
                         e.cellHtml = "通过";
                     }else if (e.value == 3){
                         e.cellHtml = "未通过";
                     }
                 }
                 if (column.name == "action") {
                     e.cellHtml = '<a class="check-botton" href="javascript:list.view()">查看</a>';
                 }
            })
        },
        //    新增或编辑
        addOrEdit: function (opt) {
        	  mini.open({
                  url: "/planning/specialPlan/new.html",
                  title: "新增计划", width: 1100, height: 350,
                  ondestroy: function (action) {
                      mini.get("datagrid1").reload();
                  }
              });
        },
        //    查看
        view: function(){
            var row = mini.get("datagrid1").getSelected();
            if (row) {
                mini.open({
                    url: "/planning/specialPlan/plannList2.html",
                    title: "主项节点", width: $(window).width(), height: 750,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = {"id": row.id,"name":row.name,"state":row.state,"auditDate":row.auditDate,"auditRemark":row.auditRemark};
                        iframe.contentWindow.view.SetData(data);
                    },
                    ondestroy: function (action) {
                        mini.get("datagrid1").reload();
                    }
                });

            } else {
                alert("请选中一条记录");
            }
        },
        //    查询
        search: function () {
            var data = {
                "name": mini.get("name").getValue(),
                "affiliatedCompanyId": mini.get("affiliatedCompanyId").getValue(),
                "cityId": mini.get("cityCombo").getValue(),
            };
            mini.get("datagrid1").load(data);
        },
        //重置
        reset:function(){
            var form = new mini.Form("qForm");
            form.reset();
            mini.get("datagrid1").load()
        },
        //    删除
        remove: function () {
            var row = mini.get("datagrid1").getSelected();
            if (row) {
                mini.confirm("确定删除选中记录？","确定",function (action) {
                    if(action=="ok"){
                        $.ajax({
                            url: "/messageRemind/del",
                            type : "post",
                            data:{"id":row.id},
                            success: function (text) {
                                if (text.state) {
                                    mini.get("datagrid1").reload();
                                } else {
                                    mini.showMessageBox({
                                        showModal: false,
                                        width: 250,
                                        title: "提示",
                                        iconCls: "mini-messagebox-warning",
                                        message: text.message,
                                    });

                                }
                            }
                        });
                    }
                });
            } else {
                alert("请选中一条记录");
            }
        }
    };
    list.init();
</script>
</body>
</html>